package com.other.src.main.java.com.kuang.pc;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

public class B {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        CompletableFuture<Void> completableFuture = CompletableFuture.runAsync(
//                ()->{
////                    try {
////                        TimeUnit.SECONDS.sleep(2);
////                    } catch (InterruptedException e) {
////                        e.printStackTrace();
////                    } finally {
////                    }
//                    System.out.println(Thread.currentThread().getName()+"runAsync -> Void");
//                }
//
//        );
//
//        System.out.println("11111");
//
//        completableFuture.get();//




        CompletableFuture<Integer> completableFuture =  CompletableFuture.supplyAsync(()->{
            System.out.println(Thread.currentThread().getName()+"supplyAsync -> Integer");
            int i = 10/0;
            return 1024;
        });
        System.out.println(completableFuture.whenComplete((t, u) -> {
            System.out.println("t=> " + t);
            System.out.println("u=> " + u);
        }).exceptionally((e) -> {
            System.out.println(e.getMessage());
            return 233;
        }).get());

    }

}
